<template>
  <div class="index">
    <Location class="index-location" type="contact"></Location>
    <div class="index-contact">
      <!-- 联系人 -->
      <div class="index-contact-column">
        <div class="index-contact-column-key">联系人：</div>
        <div class="index-contact-column-value">
          {{ page.data.lianxiren || "暂无联系人" }}
        </div>
      </div>
      <!-- 客户交流群 -->
      <div class="index-contact-column">
        <div class="index-contact-column-key">客户交流群：</div>
        <div class="index-contact-column-value">
          <div
            class="index-contact-column-value"
            v-for="(g, index) in page.data.kehujiaoliuqun"
            :key="index"
          >
            {{ page.markList[index] }}{{ g }}；
          </div>
        </div>
      </div>
      <!-- 客户QQ -->
      <div class="index-contact-column">
        <div class="index-contact-column-key">客户QQ：</div>
        <div class="index-contact-column-value">
          <div
            class="index-contact-column-value"
            v-for="(q, index) in page.data.kehu_qq"
            :key="index"
          >
            {{ page.markList[index] }}{{ q }}；
          </div>
        </div>
      </div>
      <!-- Emall -->
      <div class="index-contact-column">
        <div class="index-contact-column-key">Emall：</div>
        <div class="index-contact-column-value">{{ page.data.email }}</div>
      </div>
    </div>
    <div class="index-leave">
      <img class="index-leave-bg" src="@/assets/images/image(37).png" alt="" />
      <!-- 在线留言 -->
      <div class="index-leave-tag">
        <div class="index-leave-tag-name">在线留言</div>
        <div class="index-leave-tag-line"></div>
      </div>
      <!-- 姓名 -->
      <div class="index-leave-inputgroup">
        <img
          class="index-leave-inputgroup-icon"
          src="@/assets/images/image(17).png"
        />
        <el-input
          placeholder="请输入您的姓名"
          v-model="field.formData.name"
        ></el-input>
      </div>
      <!-- 邮箱 -->
      <div class="index-leave-inputgroup">
        <img
          class="index-leave-inputgroup-icon"
          src="@/assets/images/image(11).png"
        />
        <el-input
          placeholder="请输入您的邮箱"
          v-model="field.formData.email"
        ></el-input>
      </div>
      <!-- 联系方式 -->
      <div class="index-leave-inputgroup">
        <img
          class="index-leave-inputgroup-icon"
          src="@/assets/images/image(9).png"
        />
        <el-input
          placeholder="请输入您的联系方式"
          v-model="field.formData.phone"
        ></el-input>
      </div>
      <!-- 咨询内容 -->
      <div class="index-leave-textgroup">
        <img
          class="index-leave-textgroup-icon"
          src="@/assets/images/image(10).png"
        />
        <el-input
          type="textarea"
          placeholder="请输入您的咨询内容"
          rows="8"
          resize="none"
          size="medium"
          v-model="field.formData.content"
        ></el-input>
      </div>
      <!-- 立即提交 -->
      <div class="index-leave-confirm" @click="field.handleSubmit">
        立即提交
      </div>
    </div>
  </div>
</template>
<script setup>
import { ToastBottom, setObj, getObj } from "@/utils/index";
import { onMounted, computed, ref, reactive, toRefs, inject } from "vue";
import { useRoute, useRouter } from "vue-router";
import Location from "@/components/location/index";
import { ElMessage } from "element-plus";

//获取路由
const $_route = useRoute();
const $_router = useRouter();
//获取接口
const $_api = inject("$api");
onMounted(() => {
  //获取联系我们
  api.getAboutMe();
});
//联系我们
const api = reactive({
  getAboutMe: async () => {
    const results = await $_api.aboutMe();
    if (results && results.status > 0) {
      console.log(results.data, "aboutMe");
      page.data = results.data;
    }
  },
  postLiuYan: async () => {
    const results = await $_api.liuYan(field.formData);
    if (results && results.status > 0) {
      ElMessage.success(results.info);
    }
    cleanField();
  },
});
const page = reactive({
  data: {},
  markList: ["①", "②", "③", "④", "⑤", "⑥", "⑦"],
});
const field = reactive({
  formData: {
    name: "",
    email: "",
    phone: "",
    content: "",
  },
  handleSubmit: () => {
    api.postLiuYan();
  },
});
//清空表单
const cleanField = () => {
  field.formData.name = "";
  field.formData.email = "";
  field.formData.phone = "";
  field.formData.content = "";
  api.getAboutMe();
};
</script>

<style lang="scss" scoped>
.index {
  @include flex(flex-start, center);
  flex-direction: column;
  margin: 5px auto 0;
  width: 1200px;
}
.index-location {
  flex-shrink: 0;
  width: 100%;
  height: 105px;
}
.index-contact {
  @include flex(flex-start, flex-start);
  flex-direction: column;
  padding: 20px 0;
  box-sizing: border-box;
  width: 100%;
}
.index-contact-column {
  @include flex(flex-start, center);
  margin-bottom: 10px;
  width: 100%;
}
.index-contact-column:last-child {
  margin-bottom: 0px;
}
.index-contact-column-key {
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #2f2f2f;
  line-height: 22px;
}
.index-contact-column-value {
  @include flex(flex-start, center);
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #2f2f2f;
  line-height: 22px;
}
.index-leave {
  @include flex(flex-start, center);
  flex-direction: column;
  position: relative;
  margin-bottom: 10px;
  padding: 10px 15px 30px;
  width: 100%;
  height: 470px;
  z-index: 9;
  box-sizing: border-box;
}
.index-leave-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  right: 0;
  z-index: -1;
}
.index-leave-tag {
  @include flex(flex-start, flex-start);
  flex-direction: column;
  margin-bottom: 15px;
  width: 100%;
}
.index-leave-tag-name {
  width: 104px;
  font-size: 26px;
  font-family: PingFangSC-Medium, PingFang SC;
  font-weight: 500;
  color: #ffffff;
  line-height: 37px;
}
.index-leave-inputgroup {
  @include flex(flex-start, center);
  margin-bottom: 10px;
  width: 533px;
  height: 40px;
  background: #ffffff;
  opacity: 0.79;
  // background: rgba(255, 255, 255, 0.8);
}
.index-leave-inputgroup-icon {
  margin: 0 10px;
  width: 16px;
  height: 19px;
}
.index-leave-textgroup {
  @include flex(flex-start, flex-start);
  margin-bottom: 18px;
  padding: 10px;
  box-sizing: border-box;
  width: 533px;
  height: 173px;
  background: #ffffff;
  opacity: 0.79;
  overflow: hidden;
}
.index-leave-textgroup-icon {
  flex-shrink: 0;
  margin-right: 10px;
  width: 16px;
  height: 19px;
}

.index-leave-tag-line {
  position: relative;
  margin-top: -10px;
  width: 104px;
  height: 9px;
  background: #df7935;
  z-index: -1;
}
.index-leave-confirm {
  width: 233px;
  height: 36px;
  line-height: 36px;
  text-align: center;
  background: #df7935;
  font-size: 16px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #ffffff;
  cursor: pointer;
}
</style>
<style lang="scss" scoped>
.login-card-body-block-input :deep(.el-input__inner) {
  border-radius: 0;
  border: none;
  padding-left: 0;
}
.index-leave-inputgroup :deep(.el-input__inner) {
  border-radius: 0;
  border: none;
  padding: 0;
  &::placeholder {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #2f2f2f;
    line-height: 22px;
  }
}
.index-leave-textgroup :deep(.el-textarea__inner) {
  border-radius: 0;
  border: none;
  padding: 0;
  &::placeholder {
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #2f2f2f;
    line-height: 22px;
  }
}
</style>
